package com.rongshu.view.userInfo.presenter;

import android.content.Context;

import com.rongshu.api.RetorfitService;
import com.rongshu.view.base.mvp.BasePresenter;
import com.rongshu.view.base.mvp.INetBean;
import com.rongshu.view.userInfo.entity.RecyclerStationInfo;
import com.rongshu.view.userInfo.iview.RecyclerStationView;

import rx.Subscriber;

public class RecyclerStationPresenter extends BasePresenter<RecyclerStationView> {

    public RecyclerStationPresenter(Context context) {
        super(context);
    }

    /**
     * APP获取回收站文章名字列表
     */
    public void getRecycleBinContribute(int user_id, String sign) {
        RetorfitService.getRecycleBinContribute(user_id, sign)
                .subscribe(new Subscriber<RecyclerStationInfo>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(RecyclerStationInfo recyclerStationInfo) {
                        if (getView() != null) {
                            getView().onRecyclerStationList(recyclerStationInfo);
                        }
                    }
                });
    }

    /**
     * APP恢复已删除的文章
     */
    public void getRecoverContribute(int user_id, int contribute_id, String sign) {
        RetorfitService.getRecoverContribute(user_id, contribute_id, sign)
                .subscribe(new Subscriber<INetBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(INetBean bean) {
                        if (getView() != null) {
                            getView().onRecoverContribute(bean);
                        }
                    }
                });
    }

    /**
     * APP彻底删除文章
     */
    public void getShiftDeleteContribute(int user_id, int contribute_id, String sign) {
        RetorfitService.getShiftDeleteContribute(user_id, contribute_id, sign)
                .subscribe(new Subscriber<INetBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(INetBean bean) {
                        if (getView() != null) {
                            getView().onShiftDeleteContribute(bean);
                        }
                    }
                });
    }
}
